#/usr/bin/env python
# -*- coding: utf8 -*-
# title       :
# description :
# author      :'ShenMeng'

import pymel.core as pmel
import maya.cmds as cmds


class Validation():
    name = u'Freeze | 冻结变换检查'
    order = 10
    dataDict = dict()

    def execute(self):
        self.dataDict = {}
        objList = cmds.ls(l=1, tr=1)
        cameraList = pmel.ls(ca=1)
        for cam in cameraList:
            objList.remove(cam.getParent().longName())
        if objList:
            for obj in objList:
                obj = pmel.PyNode(obj)
                trans = list(obj.translate.get())
                rotate = list(obj.rotate.get())
                scale = list(obj.scale.get())
                if trans == rotate == [0.0, 0.0, 0.0] and scale == [1.0, 1.0, 1.0]:
                    continue
                self.dataDict[obj.name()] = []
                if trans != [0.0, 0.0, 0.0]:
                    self.dataDict[obj.name()].append('translate: %s' % str(trans))
                if rotate != [0.0, 0.0, 0.0]:
                    self.dataDict[obj.name()].append('rotate: %s' % str(rotate))
                if scale != [1.0, 1.0, 1.0]:
                    self.dataDict[obj.name()].append('scale: %s' % str(scale))

        return self.dataDict

    def correct(self):
        if self.dataDict:
            for obj in self.dataDict:
                cmds.makeIdentity(obj, apply=1, t=1, r=1, s=1, n=0, pn=1)

    def search(self, obj):
        cmds.select(obj)
